﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using XinYuanOfficeWinForm.RoleServiceReference;

namespace XinYuanOfficeWinForm.Admin.Permission
{
    public partial class FrmRoleList : Form
    {
        public int roleId;
        public string roleName;
        RoleServiceClient roleClient = new RoleServiceClient();
        public FrmRoleList()
        {
            InitializeComponent();
            dgvRoles.AutoGenerateColumns = false;
        }

        private void FrmRoleList_Load(object sender, EventArgs e)
        {
            LoadAllRole();
        }

        /// <summary>
        /// 加载角色列表
        /// </summary>
        void LoadAllRole()
        {
            DataSet ds = roleClient.GetRoles();
            dgvRoles.DataSource = ds.Tables[0];
        }

        private void dgvRoles_DataBindingComplete(object sender, DataGridViewBindingCompleteEventArgs e)
        {
            for (int i = 0; i < dgvRoles.Rows.Count; i++)
            {
                dgvRoles.Rows[i].Cells[0].ToolTipText = "双击鼠标选择";
                dgvRoles.Rows[i].Cells[1].ToolTipText = "双击鼠标选择";
            }
        }

        private void dgvRoles_CellDoubleClick(object sender, DataGridViewCellEventArgs e)
        {
            this.roleId=Convert.ToInt32(dgvRoles.CurrentRow.Cells["RoleId"].Value);
            this.roleName = Convert.ToString(dgvRoles.CurrentRow.Cells["RoleName"].Value);
            this.Close();
        }
    }
}
